#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

class Solution {
public:
    string thousandSeparator(int n) {
        string s1;
        int tmp = n;
        int i = 0;
        int count = 0;
        while (1)
        {
            s1 += to_string(n % 10);
            n /= 10;
            ++i;
            if (i == 3)
            {
                s1.push_back('.');
                count++;
                i = 0;
            }
            if (n == 0)
                break;
        }
        if (count > (ceil(string(to_string(tmp)).size() / 3.0)) - 1)
        {
            s1.resize(s1.size() - 1);
        }
        reverse(s1.begin(), s1.end());

        return s1;
    }
};